package main

import "fmt"

/*
	嵌套匿名结构体
*/

type User struct {
	UserName string
	Password string
	AddTime  string
	Address  //表示User结构体嵌套Address结构体
}

type Address struct {
	Name    string
	Phone   string
	City    string
	AddTime string
}

func main() {
	var u User
	u.UserName = "张三"
	u.Password = "456789"
	u.Address.Name = "张先生"
	u.Address.Phone = "15323132132"
	u.Address.City = "深圳市福田区"

	u.City = "上海" //当访问结构体成员时会先在结构体中查找该字段，找不到再去匿名结构体中查找

	u.AddTime = "2025-11-19"
	u.Address.AddTime = "2025-11-20"

	fmt.Printf("%#v\n", u) //main.User{UserName:"张三", Password:"456789", AddTime:"2025-11-19", Address:main.Address{Name:"张先生", Phone:"15323132132", City:"上海", AddTime:""}}

}
